/*
 *  Copyright (c) 2010-2023
 */
package net.siufung.market.base.app.controller.assembler;

import com.google.common.collect.Lists;
import net.siufung.core.utils.CopyUtil;
import net.siufung.market.base.app.controller.model.appMenu.AppMenuVo;
import net.siufung.market.base.app.mapper.entity.AppMenu;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Objects;

/**
 *
 * 系统应用菜单表 持久层展示层组装器
 *
 * @author 陈建峰
 * @since 2023-07-16 17:45:10
 * @version 1.0.0
*/
public class AppMenuAssembler {

    /**
     * AppMenu 转换成 AppMenuVo
     * @param sysAppMenu 数据实体
     * @return AppMenuVo 视图
     */
    public static AppMenuVo from(AppMenu sysAppMenu){
        if(!Objects.isNull(sysAppMenu)){
            AppMenuVo sysAppMenuVo = new AppMenuVo();
            CopyUtil.copyProperties(sysAppMenu, sysAppMenuVo);
            return sysAppMenuVo;
        }
        return null;
    }

    /**
     * SysAppMenuList 转换成 SysAppMenuVoList
     * @param sysAppMenuList 数据库实体集合
     * @return List<AppMenuVo> 视图集合
     */
    public static List<AppMenuVo> fromList(List<AppMenu> sysAppMenuList){
        List<AppMenuVo> sysAppMenuVoList = Lists.newArrayList();
        if(!CollectionUtils.isEmpty(sysAppMenuList)){
            AppMenuVo sysAppMenuVo;
            for (AppMenu sysAppMenu: sysAppMenuList) {
                sysAppMenuVo = new AppMenuVo();
                CopyUtil.copyProperties(sysAppMenu, sysAppMenuVo);
                sysAppMenuVoList.add(sysAppMenuVo);
            }
        }
        return sysAppMenuVoList;
    }
}